package com.zucai365.football.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.wcj.common.utils.SpringBeanUtils;
import com.zucai365.football.bean.LianSaiYearBean;
import com.zucai365.football.service.LianSaiInfoService;
import com.zucai365.football.service.LianSaiService;
import com.zucai365.football.service.LianSaiYearService;
import com.zucai365.football.utils.Constant;
import com.zucai365.football.utils.ZuCaiUtils;



public class SystemListener implements ServletContextListener{

	public void contextDestroyed(ServletContextEvent arg0) {
		
	}

	public void contextInitialized(ServletContextEvent event ) {
		
		Constant.WAR_PATH = event.getServletContext().getRealPath( "/" );
		LianSaiService lianSaiService = (LianSaiService) SpringBeanUtils.getBean( "lianSaiService" );
		LianSaiYearService lianSaiYearService = (LianSaiYearService) SpringBeanUtils.getBean( "lianSaiYearService" );
		LianSaiInfoService lianSaiInfoService = (LianSaiInfoService) SpringBeanUtils.getBean( "lianSaiInfoService" );

		Constant.ALL_LIANSAI_LIST = lianSaiService.getAllLianSai();
		Constant.ALL_LIANSAI_YEAR_LIST = lianSaiYearService.getAllLianSaiYear();
		
		for( LianSaiYearBean lianSaiYear : Constant.ALL_LIANSAI_YEAR_LIST ){
			if( lianSaiYear.getIsCurrentTime() == 1 ){
				ZuCaiUtils.CURRENT_LIANSAI_YEAR = lianSaiYear.getId() ;
				break;
			}			
		}
		
		ZuCaiUtils.CURRENT_LIANSAI=Constant.ALL_LIANSAI_LIST.get(0).getId();
		
		Constant.ALL_LIANSAI_INFO_LIST=lianSaiInfoService.findAll();
		
//		
//		ZuCaiUtils.DEFAULT_GAME_TYPE="1";
		
//		String autosubmitdata = PropertiesUtils.getConfigValue( "autosubmitdata" );
//		if( StringUtils.isBlank( autosubmitdata ) ){
//			autosubmitdata="false";
//		}
//		ZuCaiUtils.AUTO_SUBMIT_DATA= autosubmitdata ;
//		
//		Constant.GAMEFIREDATAPATH = PropertiesUtils.getConfigValue( "gameFireDataPath" ).replace( "\\" , "/" );
//				
//		if( !Constant.GAMEFIREDATAPATH.endsWith( "/" ) ){
//			Constant.GAMEFIREDATAPATH += File.separator;
//		}

	}
	
}
